#include "globalOptionsPanel.h"
#include "defines/inputSpringType.h"

GlobalOptionsPanel::GlobalOptionsPanel(QWidget *_parent) : QWidget(_parent){
    gravity = -9.81;
    deltaT = 0.001;
    adjacency = EIGHT_ADJACENCY;


    QLabel *gravityLabel = new QLabel(tr("Gravidade:"));

    QDoubleSpinBox *gravityDoubleSpinBox = new QDoubleSpinBox();
    gravityDoubleSpinBox->setRange(-50, 50.0);
    gravityDoubleSpinBox->setSingleStep(1.0);
    gravityDoubleSpinBox->setValue(gravity);
    connect(gravityDoubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(changeGravity(double)));

    QHBoxLayout *gravityLayout = new QHBoxLayout;
    gravityLayout->addWidget(gravityLabel);
    gravityLayout->addWidget(gravityDoubleSpinBox);




    QLabel *deltaTLabel = new QLabel(tr("Delta T:"));

    QDoubleSpinBox *deltaTDoubleSpinBox = new QDoubleSpinBox();
    deltaTDoubleSpinBox->setRange(0.0000000001, 5);
    deltaTDoubleSpinBox->setSingleStep(0.00001);
    deltaTDoubleSpinBox->setDecimals(10);
    deltaTDoubleSpinBox->setValue(deltaT);
    connect(deltaTDoubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(changeDeltaT(double)));

    QHBoxLayout *deltaTLayout = new QHBoxLayout;
    deltaTLayout->addWidget(deltaTLabel);
    deltaTLayout->addWidget(deltaTDoubleSpinBox);




    //------------------------------------Tipo
    QLabel *adjacencyLabel = new QLabel(QString::fromUtf8("Adjacência:"));

    QComboBox *adjacencyComboBox = new QComboBox;
    adjacencyComboBox->addItem(tr("8"));
    adjacencyComboBox->addItem(tr("4"));
    connect(adjacencyComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changeAdjacency(int)));

    QHBoxLayout *adjacencyLayout = new QHBoxLayout;
    adjacencyLayout->addWidget(adjacencyLabel);
    adjacencyLayout->addWidget(adjacencyComboBox);




    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(gravityLayout);
    mainLayout->addLayout(deltaTLayout);
    mainLayout->addLayout(adjacencyLayout);
    mainLayout->addStretch(1);

    setLayout(mainLayout);
}
